package main;

public class XYCoordinateWithdValue extends XYCoordinate {

	public XYCoordinateWithdValue(int x, int y, double value) {
		super(x, y);
		this.value = value;
	}
	
	public XYCoordinateWithdValue(XYCoordinateWithdValue xy) {
		super(xy);
		this.value = xy.value;
		this.bottom = xy.bottom;
		this.top = xy.top;
		this.left = xy.left;
		this.right = xy.right;
	}
	
	/**
	 * Gets value stored in this object
	 * @return double
	 */
	public double getValue() {
		return value;
	}
	
	/**
	 * Sets the value stored in this double to value
	 * @param value
	 */
	public void setValue(double value) {
		this.value = value;
	}
	
	/**
	 * Sets the neighbor for this cell in direction
	 * @param direction 
	 * @param value
	 */
	public void setNeighbor(int direction, XYCoordinateWithdValue value) {
		switch(direction) {
		case ICoordinate.DIR_BOTTOM:
			bottom = value;
			break;
		case ICoordinate.DIR_LEFT:
			left = value;
			break;
		case ICoordinate.DIR_RIGHT:
			right = value;
			break;
		case ICoordinate.DIR_TOP:
			top = value;
			break;
		default:
			return;
		}
	}
	
	/* Overriden */
	public ICoordinate getNeighbor(int direction) {
		switch(direction) {
		case ICoordinate.DIR_BOTTOM:
			return bottom;
		case ICoordinate.DIR_LEFT:
			return left;
		case ICoordinate.DIR_RIGHT:
			return right;
		case ICoordinate.DIR_TOP:
			return top;
		default:
			return null;
		}
	}
	
	/* Private */
	protected double value;
	protected XYCoordinateWithdValue left, right, top, bottom;
}